#include "pch.h"
#include "GLBuffer.h"
#include <glad/glad.h>
namespace HS  {
	// ===================
	// OpenGL VertexBuffer
	GLVertexBuffer::~GLVertexBuffer()
	{
		glDeleteBuffers(1, &m_Handle);
	}

	void GLVertexBuffer::Bind() const
	{
		glBindBuffer(GL_ARRAY_BUFFER,m_Handle);
	}

	void GLVertexBuffer::UnBind() const
	{
		glBindBuffer(GL_ARRAY_BUFFER, 0);
	}

	GLVertexBuffer::GLVertexBuffer(float* vertics, unsigned int size)
	{
		glCreateBuffers(1, &m_Handle);
		glBindBuffer(GL_ARRAY_BUFFER,m_Handle);
		glBufferData(GL_ARRAY_BUFFER, size, vertics, GL_STATIC_DRAW);
	}

	// OpenGL VertexBuffer
	// ===================



	//  ==================
	//  OpenGL IndexBuffer
	GLIndexBuffer::~GLIndexBuffer()
	{
		glDeleteBuffers(1, &m_Handle);
	}

	void GLIndexBuffer::Bind() const
	{
		glBindBuffer(GL_ARRAY_BUFFER, m_Handle);
	}

	void GLIndexBuffer::UnBind() const
	{
		glBindBuffer(GL_ARRAY_BUFFER, 0);
	}

	GLIndexBuffer::GLIndexBuffer(unsigned int* indices, uint32_t count)
	{
		m_Count = count;
		glCreateBuffers(1, &m_Handle);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Handle);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER, count*sizeof(uint32_t), indices, GL_STATIC_DRAW);
	}

	//  OpenGL IndexBuffer
	//  ==================

}
